﻿function ClientUpdateLanguageMan()
{
    retValue=Portal.SystemWebParts.LanguageMan.LanguageMan.ServerSideAutoUpdate().value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    alert(retValue);
}

function RunFilter()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.LanguageMan.LanguageMan.GetProcessingText().value;
    setTimeout("RealRunFilter()",10);
}

function RealRunFilter()
{
    PageIndex=0;
    if(document.getElementById("divSelectPage")!=null)
    {
        PageIndex=document.getElementById("divSelectPage").selectedIndex;
    }
    CurrentLanguage=document.getElementById("drpSelectLanguageForSet").options[document.getElementById("drpSelectLanguageForSet").selectedIndex].value;
    fromKeyword=document.getElementById("txtFromKeyword").value;
    toKeyword=document.getElementById("txtToKeyword").value;
    value=Portal.SystemWebParts.LanguageMan.LanguageMan.GetLanguageMan(CurrentLanguage,fromKeyword,toKeyword,PageIndex).value;
    if(value.indexOf("ERROR")!=-1)
    {
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divLanguageManContent").innerHTML=value;
}


function DoSearchAndReplace()
{
    fromKeyword=document.getElementById("txtFromKeyword").value;
    toKeyword=document.getElementById("txtToKeyword").value;
    
    CheckMsg=Portal.SystemWebParts.LanguageMan.LanguageMan.ServerSideCheck(fromKeyword,toKeyword).value;
    if(CheckMsg.indexOf("ERROR")!=-1)
    {
        alert(CheckMsg);
        return;
    }
    
    Msg=Portal.SystemWebParts.LanguageMan.LanguageMan.GetConfirmReplaceMsg().value;
    if(confirm(Msg)==false)return;
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.LanguageMan.LanguageMan.GetProcessingText().value;
    setTimeout("RealRealRunFilter()",10);
}

function RealRealRunFilter()
{
    CurrentLanguage=document.getElementById("drpSelectLanguageForSet").options[document.getElementById("drpSelectLanguageForSet").selectedIndex].value;
    fromKeyword=document.getElementById("txtFromKeyword").value;
    toKeyword=document.getElementById("txtToKeyword").value;
    value=Portal.SystemWebParts.LanguageMan.LanguageMan.ServerSideSearchAndReplace(CurrentLanguage,fromKeyword,toKeyword).value;
    if(value.indexOf("ERROR")!=-1)
    {
        alert(value);
        return;
    }
    alert(value);
    document.getElementById("divProcessing").innerHTML="";
}


function RunFilterFrontEnd()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.LanguageMan.FrontEndLanguageMan.GetProcessingText().value;
    setTimeout("RealRunFilterFrontEnd()",10);
}

function RealRunFilterFrontEnd()
{
    PageIndex=0;
    if(document.getElementById("divSelectPage")!=null)
    {
        PageIndex=document.getElementById("divSelectPage").selectedIndex;
    }
    CurrentLanguage=document.getElementById("drpSelectLanguageForSet").options[document.getElementById("drpSelectLanguageForSet").selectedIndex].value;
    belongSite=document.getElementById("drpSelectSite").options[document.getElementById("drpSelectSite").selectedIndex].value;
    //alert(CurrentLanguage);
    value=Portal.SystemWebParts.LanguageMan.FrontEndLanguageMan.GetFrontEndLanguageMan(belongSite,CurrentLanguage,PageIndex).value;
    if(value.indexOf("ERROR")!=-1)
    {
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divFrontEndLanguageManContent").innerHTML=value;
}



function SaveLanguage(Language,XmlFile,MaxItems)
{
    for(var iIndex=0;iIndex<MaxItems;iIndex++)
    {
        Id=document.getElementById("txtId"+iIndex).value;
        Value=document.getElementById("txtValue"+iIndex).value;
        Portal.SystemWebParts.LanguageMan.EditLanguage.ServerSideSaveLanguage(Language,XmlFile,Id,Value);
    }
    alert(Portal.SystemWebParts.LanguageMan.EditLanguage.GetSaveOk().value);
}

function SaveLanguageFrontEnd(belongSite,Language,XmlFile,MaxItems)
{
    for(var iIndex=0;iIndex<MaxItems;iIndex++)
    {
        Id=document.getElementById("txtId"+iIndex).value;
        Value=document.getElementById("txtValue"+iIndex).value;
        Portal.SystemWebParts.LanguageMan.FrontEndEditLanguage.ServerSideSaveLanguage(belongSite,Language,XmlFile,Id,Value);
    }
    alert(Portal.SystemWebParts.LanguageMan.FrontEndEditLanguage.GetSaveOk().value);
}


function UpdateLanguageTable()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.LanguageMan.LanguageMan.GetProcessingText().value;
    setTimeout("RealUpdateLanguageTable()",10);
}

function RealUpdateLanguageTable()
{
    value=Portal.SystemWebParts.LanguageMan.LanguageMan.UpdateLanguageTable().value;
    if(value.indexOf("ERROR")!=-1)
    {
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    alert(value);
}